package com.ding.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.boot.autoconfigure.web.ErrorProperties;
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ErrorController extends BasicErrorController{
	public ErrorController(ErrorAttributes errorAttributes, ErrorProperties errorProperties) {
		super(errorAttributes, errorProperties);
	}
	
	
	@Override
	public ResponseEntity<Map<String, Object>> error(HttpServletRequest req) {
		return super.error(req);
	}
	
	@Override
	public ModelAndView errorHtml(HttpServletRequest req, HttpServletResponse response) {
		
		ModelAndView modelAndView = super.errorHtml(req, response);
		
		System.out.println("Error Model中的数据");
		
		Map<String, Object> model = modelAndView.getModel();
		
		for (String key : model.keySet()) {
			System.out.println(key+" : "+model.get(key));
		}
		
		return modelAndView;
	}
	
}
